package com.huawei.classroom.student.h57;

import java.io.File;

public class FileTool {

	/*
	 * 统计一个目录下所有文件大小的加和
	 */
	
	public long recursiveCalcFileSize(String homeDir) {
		long size_sum = 0;
		File home = new File(homeDir);
		File[] listfiles = home.listFiles();
		for(int i=0; i<listfiles.length; i++) {
			if(listfiles[i].isDirectory()) {
				long t = recursiveCalcFileSize(listfiles[i].getPath());
				size_sum += t;
			}else {
				size_sum += listfiles[i].length();
			}
		}
		return size_sum;
	}
}
